Skip to content

fix: Improve Timers error handling and web compatibility (fixes #45085)#45105

Closed
robik wants to merge 1 commit into
facebook:mainfrom
robik:robik/fix-timer-errors-new-arch
Closed

fix: Improve Timers error handling and web compatibility (fixes #45085)#45105
robik wants to merge 1 commit into
facebook:mainfrom
robik:robik/fix-timer-errors-new-arch

Conversation

@robik
Copy link
Copy Markdown
Contributor

@robik robik commented Jun 21, 2024

Summary:

Improve compatibility with web implementations of JS timers.

Fixes #45085

Changelog:

[GENERAL] [CHANGED] - Timer functions are now throwing exceptions in less cases and are instead quiet quitting (similar to browsers)
[GENERAL] [CHANGED] - Timer functions timeout argument is now coerced to a number

Test Plan:

Updated RN tester

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jun 21, 2024
@robik robik force-pushed the robik/fix-timer-errors-new-arch branch from f38db81 to d5f09dd Compare June 21, 2024 13:20
Copy link
Copy Markdown
Member

@javache javache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving this, a few small tweaks please.

Comment thread packages/react-native/ReactCommon/react/runtime/TimerManager.cpp Outdated
Comment thread packages/react-native/ReactCommon/react/runtime/TimerManager.cpp Outdated
Comment thread packages/react-native/ReactCommon/react/runtime/TimerManager.cpp Outdated
@robik robik force-pushed the robik/fix-timer-errors-new-arch branch from c63a2ac to 8cfa43b Compare June 24, 2024 11:48
@javache
Copy link
Copy Markdown
Member

javache commented Jun 24, 2024

Please also rebase to main, there are some conflicts.

@robik robik force-pushed the robik/fix-timer-errors-new-arch branch from 8cfa43b to 3d419f5 Compare June 24, 2024 13:00
@robik
Copy link
Copy Markdown
Contributor Author

robik commented Jun 24, 2024

Please also rebase to main, there are some conflicts.

Rebased, should be good now :)

@analysis-bot
Copy link
Copy Markdown

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 20,478,833 +96
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 23,676,545 +22
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 6bb75c7
Branch: main

auto callback = args[0].getObject(rt).getFunction(rt);
auto delay =
count > 1 && args[1].isNumber() ? args[1].getNumber() : 0;
auto delay = count > 1 ? coerceNumberTimeout(rt, jsi::Value { rt, args[1] }) : 0.0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no need to create a new jsi::Value here

Suggested change
auto delay = count > 1 ? coerceNumberTimeout(rt, jsi::Value { rt, args[1] }) : 0.0;
auto delay = count > 1 ? coerceNumberTimeout(rt, args[1]) : 0.0;

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@javache merged this pull request in af04eb7.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 24, 2024
@github-actions
Copy link
Copy Markdown

This pull request was successfully merged by @robik in af04eb7.

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timers in the new architecture are not spec compliant

4 participants